#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        int xorRes = 0;
        for (auto e : nums) {
            xorRes ^= e;
        }
        int mask = 1;
        while ((mask & xorRes) == 0) {
            mask <<= 1;
        }
        int a = 0, b = 0;
        for (auto e : nums) {
            if (e & mask) {
                a ^= e;
            }
            else
                b ^= e;
        }
        vector<int> ret = { a,b };
        return ret;
    }
};